<?php

use Dcat\Admin\Admin;
use Dcat\Admin\Grid;
use Dcat\Admin\Form;
use Dcat\Admin\Grid\Filter;
use Dcat\Admin\Show;
use Dcat\Admin\Widgets\Modal;

/**
 * Dcat-admin - admin builder based on Laravel.
 * @author jqh <https://github.com/jqhph>
 *
 * Bootstraper for Admin.
 *
 * Here you can remove builtin form field:
 *
 * extend custom field:
 * Dcat\Admin\Form::extend('php', PHPEditor::class);
 * Dcat\Admin\Grid\Column::extend('php', PHPEditor::class);
 * Dcat\Admin\Grid\Filter::extend('php', PHPEditor::class);
 *
 * Or require js and css assets:
 * Admin::css('/packages/prettydocs/css/styles.css');
 * Admin::js('/packages/prettydocs/js/main.js');
 *
 */

// 覆盖默认配置
config(['admin' => user_admin_config()]);
config(['app.locale' => config('admin.lang') ?: config('app.locale')]);

Admin::style('.main-sidebar .nav-sidebar .nav-item>.nav-link {
    border-radius: .1rem;
}');

#GRID统一设置
Grid::resolving(function (Grid $grid) {
    if (! request('_row_')) {
        $grid->tableCollapse();
    }
    #$grid->withBorder();
    $grid->toolsWithOutline(false);
    $grid->disableBatchActions();
    $grid->disableRowSelector();

});

// 扩展Column
Grid\Column::extend('code', function ($v) {
    return "<code>$v</code>";
});

if (!Admin::user()){
    return null;
}

Admin::navbar(function (\Dcat\Admin\Layout\Navbar $navbar) {


    // ajax请求不执行
    if (! Dcat\Admin\Support\Helper::isAjaxRequest()) {
       //$navbar->right(App\Admin\Actions\AdminSetting::make()->render());

        $navbar->right(App\Admin\Actions\UserProfileAction::make()->render());
        $navbar->right(App\Admin\Actions\NotificationAction::make()->render());


        //$navbar->right(view('admin.navbar-1'));
    }

    // 下拉菜单
    //$navbar->right(view('admin.navbar-2'));

    // 搜索框
    /*$navbar->right(
        <<<HTML
HTML
    );*/

});

#修改
admin_inject_default_section(Admin::SECTION['NAVBAR_USER_PANEL'], function () {
    return view('admin.navbar-user-panel', [
        'user' => Admin::user(),
    ]);
});
